package com.ssd.controller;

import com.ssd.entity.ChannelEntity;
import com.ssd.entity.VmTypeEntity;
import com.ssd.entity.dto.ChannelConfigDto;
import com.ssd.service.ChannelService;
import com.ssd.view.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/channel")
@Slf4j
public class ChannelController {

    @Resource
    private ChannelService channelService;

    @GetMapping("/list/{innerCode}")
    public BaseResponse<List<ChannelEntity>> getVMTypePage(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10000") Integer pageSize,
            @PathVariable String innerCode) {
        return new BaseResponse(channelService.getChannelList(pageNum, pageSize,innerCode));
    }

    /**
     * 修改售货机货道
     */
    @PutMapping("/config")
    public BaseResponse edit(@RequestBody ChannelConfigDto channelConfigDto) {
        return new BaseResponse(channelService.updateChannel(channelConfigDto));
    }

    @GetMapping("/{innerCode}")
    public BaseResponse<List<ChannelEntity>> getChannelList(@PathVariable String innerCode){
        return new BaseResponse<>(channelService.getChannelList(innerCode));
    }
}